﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace GF5_Fight_Sim_v1
{
    public partial class Form1 : Form
    {
        Armory arm = new Armory();

        List<Unit> YourList = new List<Unit>();
        List<Unit> OpList = new List<Unit>();

        private double YourAttack;
        private double YourHealth;
        private double OpAttack;
        private double OpHealth;
        private double YourAttackBonus;
        private double YourHealthBonus;
        private double OpAttackBonus;
        private double OpHealthBonus;

        #region Default Attack Values
        private double ThugAtt = 22;
        private double ArsoAtt = 11;
        private double DemoAtt = 51;
        private double BruiAtt = 28;
        private double HitmAtt = 75;
        private double EnfoAtt = 235;
        private double TommAtt = 142;
        private double ProfAtt = 754;
        private double CourAtt = 1;
        private double DeliAtt = 2;
        #endregion

        #region Default Health Values
        private double ThugHea = 111;
        private double ArsoHea = 224;
        private double DemoHea = 257;
        private double BruiHea = 562;
        private double HitmHea = 700;
        private double EnfoHea = 1177;
        private double TommHea = 2836;
        private double ProfHea = 3779;
        private double CourHea = 100;
        private double DeliHea = 800;
        #endregion

        #region UnitValues
        double ThugAttack;
        double ArsoAttack;
        double DemoAttack;
        double BruiAttack;
        double HitmAttack;
        double EnfoAttack;
        double TommAttack;
        double ProfAttack;
        double CourAttack;
        double DeliAttack;

        double ThugAttack2;
        double ArsoAttack2;
        double DemoAttack2;
        double BruiAttack2;
        double HitmAttack2;
        double EnfoAttack2;
        double TommAttack2;
        double ProfAttack2;
        double CourAttack2;
        double DeliAttack2;

        double ArsoAttack3;
        double DemoAttack3;
        double BruiAttack3;
        double HitmAttack3;
        double EnfoAttack3;
        double TommAttack3;
        double ProfAttack3;

        double OpThugAttack;
        double OpArsoAttack;
        double OpDemoAttack;
        double OpBruiAttack;
        double OpHitmAttack;
        double OpEnfoAttack;
        double OpTommAttack;
        double OpProfAttack;
        double OpCourAttack;
        double OpDeliAttack;

        double OpThugAttack2;
        double OpArsoAttack2;
        double OpDemoAttack2;
        double OpBruiAttack2;
        double OpHitmAttack2;
        double OpEnfoAttack2;
        double OpTommAttack2;
        double OpProfAttack2;
        double OpCourAttack2;
        double OpDeliAttack2;

        double OpArsoAttack3;
        double OpDemoAttack3;
        double OpBruiAttack3;
        double OpHitmAttack3;
        double OpEnfoAttack3;
        double OpTommAttack3;
        double OpProfAttack3;

        double ThugHealth;
        double ArsoHealth;
        double DemoHealth;
        double BruiHealth;
        double HitmHealth;
        double EnfoHealth;
        double TommHealth;
        double ProfHealth;
        double CourHealth;
        double DeliHealth;

        double ThugHealth2;
        double ArsoHealth2;
        double DemoHealth2;
        double BruiHealth2;
        double HitmHealth2;
        double EnfoHealth2;
        double TommHealth2;
        double ProfHealth2;
        double CourHealth2;
        double DeliHealth2;

        double OpThugHealth;
        double OpArsoHealth;
        double OpDemoHealth;
        double OpBruiHealth;
        double OpHitmHealth;
        double OpEnfoHealth;
        double OpTommHealth;
        double OpProfHealth;
        double OpCourHealth;
        double OpDeliHealth;

        double OpThugHealth2;
        double OpArsoHealth2;
        double OpDemoHealth2;
        double OpBruiHealth2;
        double OpHitmHealth2;
        double OpEnfoHealth2;
        double OpTommHealth2;
        double OpProfHealth2;
        double OpCourHealth2;
        double OpDeliHealth2;
        #endregion

        #region UnitAmount
        double YThug;
        double YArso;
        double YDemo;
        double YBrui;
        double YHitm;
        double YEnfo;
        double YTomm;
        double YProf;
        double YCour;
        double YDeli;
        double OThug;
        double OArso;
        double ODemo;
        double OBrui;
        double OHitm;
        double OEnfo;
        double OTomm;
        double OProf;
        double OCour;
        double ODeli;
        #endregion

        public Form1()
        {
            InitializeComponent();
            textBox1.Text = "5";
            textBox2.Text = "5";
            textBox3.Text = "5";
            textBox17.Text = "5";
            textBox18.Text = "5";
            textBox19.Text = "5";
            textBox20.Text = "5";
            textBox4.Text = "5";

        }

        private void getYourUnitAmount()
        {
            YThug = Convert.ToDouble(textBox5.Text);
            YArso = Convert.ToDouble(textBox6.Text);
            YDemo = Convert.ToDouble(textBox7.Text);
            YBrui = Convert.ToDouble(textBox8.Text);
            YHitm = Convert.ToDouble(textBox9.Text);
            YEnfo = Convert.ToDouble(textBox10.Text);
            YTomm = Convert.ToDouble(textBox11.Text);
            YProf = Convert.ToDouble(textBox12.Text);
            YCour = Convert.ToDouble(textBox13.Text);
            YDeli = Convert.ToDouble(textBox14.Text);
        }

        private void getOpUnitAmount()
        {
            OThug = Convert.ToDouble(textBox30.Text);
            OArso = Convert.ToDouble(textBox29.Text);
            ODemo = Convert.ToDouble(textBox28.Text);
            OBrui = Convert.ToDouble(textBox27.Text);
            OHitm = Convert.ToDouble(textBox26.Text);
            OEnfo = Convert.ToDouble(textBox25.Text);
            OTomm = Convert.ToDouble(textBox24.Text);
            OProf = Convert.ToDouble(textBox23.Text);
            OCour = Convert.ToDouble(textBox22.Text);
            ODeli = Convert.ToDouble(textBox21.Text);
        }

        private void yourAttackPower()
        {
            YourAttackBonus = getAttackBonus();

            ThugAttack = ThugAtt + (ThugAtt / 100 * YourAttackBonus);
            ArsoAttack = ArsoAtt + (ArsoAtt / 100 * YourAttackBonus);
            DemoAttack = DemoAtt + (DemoAtt / 100 * YourAttackBonus);
            BruiAttack = BruiAtt + (BruiAtt / 100 * YourAttackBonus);
            HitmAttack = HitmAtt + (HitmAtt / 100 * YourAttackBonus);
            EnfoAttack = EnfoAtt + (EnfoAtt / 100 * YourAttackBonus);
            TommAttack = TommAtt + (TommAtt / 100 * YourAttackBonus);
            ProfAttack = ProfAtt + (ProfAtt / 100 * YourAttackBonus);
            CourAttack = CourAtt + (CourAtt / 100 * YourAttackBonus);
            DeliAttack = DeliAtt + (DeliAtt / 100 * YourAttackBonus);

            ThugAttack2 = (YThug * ThugAtt) + (YThug * (ThugAtt / 100 * YourAttackBonus));
            ArsoAttack2 = (YArso * ArsoAtt) + (YArso * (ArsoAtt / 100 * YourAttackBonus));
            DemoAttack2 = (YDemo * DemoAtt) + (YDemo * (DemoAtt / 100 * YourAttackBonus));
            BruiAttack2 = (YBrui * BruiAtt) + (YBrui * (BruiAtt / 100 * YourAttackBonus));
            HitmAttack2 = (YHitm * HitmAtt) + (YHitm * (HitmAtt / 100 * YourAttackBonus));
            EnfoAttack2 = (YEnfo * EnfoAtt) + (YEnfo * (EnfoAtt / 100 * YourAttackBonus));
            TommAttack2 = (YTomm * TommAtt) + (YTomm * (TommAtt / 100 * YourAttackBonus));
            ProfAttack2 = (YProf * ProfAtt) + (YProf * (ProfAtt / 100 * YourAttackBonus));
            CourAttack2 = (YCour * CourAtt) + (YCour * (CourAtt / 100 * YourAttackBonus));
            DeliAttack2 = (YDeli * DeliAtt) + (YDeli * (DeliAtt / 100 * YourAttackBonus));

            #region AttackBonus
            double YourAttackBonus2 = getAttackBonus() + 50;
            ArsoAttack3 = (YArso * ArsoAtt) + (YArso * (ArsoAtt / 100 * YourAttackBonus2));
            DemoAttack3 = (YDemo * DemoAtt) + (YDemo * (DemoAtt / 100 * YourAttackBonus2));
            BruiAttack3 = (YBrui * BruiAtt) + (YBrui * (BruiAtt / 100 * YourAttackBonus2));
            HitmAttack3 = (YHitm * HitmAtt) + (YHitm * (HitmAtt / 100 * YourAttackBonus2));
            EnfoAttack3 = (YEnfo * EnfoAtt) + (YEnfo * (EnfoAtt / 100 * YourAttackBonus2));
            TommAttack3 = (YTomm * TommAtt) + (YTomm * (TommAtt / 100 * YourAttackBonus2));
            ProfAttack3 = (YProf * ProfAtt) + (YProf * (ProfAtt / 100 * YourAttackBonus2));
            #endregion

            YourAttack = ThugAttack2 + ArsoAttack2 + DemoAttack2 + BruiAttack2 + HitmAttack2 + EnfoAttack2 + TommAttack2 + ProfAttack2 + CourAttack2 + DeliAttack2;
            textBox15.Text = YourAttack.ToString();
        }

        private void yourHealthPower()
        {
            YourHealthBonus = getHealthBonus();

            ThugHealth = ThugHea + (ThugHea / 100 * YourHealthBonus);
            ArsoHealth = ArsoHea + (ArsoHea / 100 * YourHealthBonus);
            DemoHealth = DemoHea + (DemoHea / 100 * YourHealthBonus);
            BruiHealth = BruiHea + (BruiHea / 100 * YourHealthBonus);
            HitmHealth = HitmHea + (HitmHea / 100 * YourHealthBonus);
            EnfoHealth = EnfoHea + (EnfoHea / 100 * YourHealthBonus);
            TommHealth = TommHea + (TommHea / 100 * YourHealthBonus);
            ProfHealth = ProfHea + (ProfHea / 100 * YourHealthBonus);
            CourHealth = CourHea + (CourHea / 100 * YourHealthBonus);
            DeliHealth = DeliHea + (DeliHea / 100 * YourHealthBonus);

            ThugHealth2 = (Convert.ToDouble(textBox5.Text) * ThugHea) + (Convert.ToDouble(textBox5.Text) * (ThugHea / 100 * YourHealthBonus));
            ArsoHealth2 = (Convert.ToDouble(textBox6.Text) * ArsoHea) + (Convert.ToDouble(textBox6.Text) * (ArsoHea / 100 * YourHealthBonus));
            DemoHealth2 = (Convert.ToDouble(textBox7.Text) * DemoHea) + (Convert.ToDouble(textBox7.Text) * (DemoHea / 100 * YourHealthBonus));
            BruiHealth2 = (Convert.ToDouble(textBox8.Text) * BruiHea) + (Convert.ToDouble(textBox8.Text) * (BruiHea / 100 * YourHealthBonus));
            HitmHealth2 = (Convert.ToDouble(textBox8.Text) * HitmHea) + (Convert.ToDouble(textBox9.Text) * (HitmHea / 100 * YourHealthBonus));
            EnfoHealth2 = (Convert.ToDouble(textBox10.Text) * EnfoHea) + (Convert.ToDouble(textBox10.Text) * (EnfoHea / 100 * YourHealthBonus));
            TommHealth2 = (Convert.ToDouble(textBox11.Text) * TommHea) + (Convert.ToDouble(textBox11.Text) * (TommHea / 100 * YourHealthBonus));
            ProfHealth2 = (Convert.ToDouble(textBox12.Text) * ProfHea) + (Convert.ToDouble(textBox12.Text) * (ProfHea / 100 * YourHealthBonus));
            CourHealth2 = (Convert.ToDouble(textBox13.Text) * CourHea) + (Convert.ToDouble(textBox13.Text) * (CourHea / 100 * YourHealthBonus));
            DeliHealth2 = (Convert.ToDouble(textBox14.Text) * DeliHea) + (Convert.ToDouble(textBox14.Text) * (DeliHea / 100 * YourHealthBonus));
            YourHealth = ThugHealth2 + ArsoHealth2 + DemoHealth2 + BruiHealth2 + HitmHealth2 + EnfoHealth2 + TommHealth2 + ProfHealth2 + CourHealth2 + DeliHealth2;
            textBox16.Text = YourHealth.ToString();
        }

        private void opAttackPower()
        {
            OpAttackBonus = getOpAttackBonus();

            OpThugAttack = ThugAtt + (ThugAtt / 100 * OpAttackBonus);
            OpArsoAttack = ArsoAtt + (ArsoAtt / 100 * OpAttackBonus);
            OpDemoAttack = DemoAtt + (DemoAtt / 100 * OpAttackBonus);
            OpBruiAttack = BruiAtt + (BruiAtt / 100 * OpAttackBonus);
            OpHitmAttack = HitmAtt + (HitmAtt / 100 * OpAttackBonus);
            OpEnfoAttack = EnfoAtt + (EnfoAtt / 100 * OpAttackBonus);
            OpTommAttack = TommAtt + (TommAtt / 100 * OpAttackBonus);
            OpProfAttack = ProfAtt + (ProfAtt / 100 * OpAttackBonus);
            OpCourAttack = CourAtt + (CourAtt / 100 * OpAttackBonus);
            OpDeliAttack = DeliAtt + (DeliAtt / 100 * OpAttackBonus);

            OpThugAttack2 = (OThug * ThugAtt) + (OThug * (ThugAtt / 100 * OpAttackBonus));
            OpArsoAttack2 = (OArso * ArsoAtt) + (OArso * (ArsoAtt / 100 * OpAttackBonus));
            OpDemoAttack2 = (ODemo * DemoAtt) + (ODemo * (DemoAtt / 100 * OpAttackBonus));
            OpBruiAttack2 = (OBrui * BruiAtt) + (OBrui * (BruiAtt / 100 * OpAttackBonus));
            OpHitmAttack2 = (OHitm * HitmAtt) + (OHitm * (HitmAtt / 100 * OpAttackBonus));
            OpEnfoAttack2 = (OEnfo * EnfoAtt) + (OEnfo * (EnfoAtt / 100 * OpAttackBonus));
            OpTommAttack2 = (OTomm * TommAtt) + (OTomm * (TommAtt / 100 * OpAttackBonus));
            OpProfAttack2 = (OProf * ProfAtt) + (OProf * (ProfAtt / 100 * OpAttackBonus));
            OpCourAttack2 = (OCour * CourAtt) + (OCour * (CourAtt / 100 * OpAttackBonus));
            OpDeliAttack2 = (ODeli * DeliAtt) + (ODeli * (DeliAtt / 100 * OpAttackBonus));

            #region AttackBonus
            double OpAttackBonus2 = getAttackBonus() + 50;
            OpArsoAttack3 = (OArso * ArsoAtt) + (OArso * (ArsoAtt / 100 * OpAttackBonus2));
            OpDemoAttack3 = (ODemo * DemoAtt) + (ODemo * (DemoAtt / 100 * OpAttackBonus2));
            OpBruiAttack3 = (OBrui * BruiAtt) + (OBrui * (BruiAtt / 100 * OpAttackBonus2));
            OpHitmAttack3 = (OHitm * HitmAtt) + (OHitm * (HitmAtt / 100 * OpAttackBonus2));
            OpEnfoAttack3 = (OEnfo * EnfoAtt) + (OEnfo * (EnfoAtt / 100 * OpAttackBonus2));
            OpTommAttack3 = (OTomm * TommAtt) + (OTomm * (TommAtt / 100 * OpAttackBonus2));
            OpProfAttack3 = (OProf * ProfAtt) + (OProf * (ProfAtt / 100 * OpAttackBonus2));
            #endregion


            OpAttack = OpThugAttack2 + OpArsoAttack2 + OpDemoAttack2 + OpBruiAttack2 + OpHitmAttack2 + OpEnfoAttack2 + OpTommAttack2 + OpProfAttack2 + OpCourAttack2 + OpDeliAttack2;
            textBox32.Text = OpAttack.ToString();
        }

        private void opHealthPower()
        {
            OpHealthBonus = getOpHealthBonus();

            OpThugHealth = ThugHea + (ThugHea / 100 * OpHealthBonus);
            OpArsoHealth = ArsoHea + (ArsoHea / 100 * OpHealthBonus);
            OpDemoHealth = DemoHea + (DemoHea / 100 * OpHealthBonus);
            OpBruiHealth = BruiHea + (BruiHea / 100 * OpHealthBonus);
            OpHitmHealth = HitmHea + (HitmHea / 100 * OpHealthBonus);
            OpEnfoHealth = EnfoHea + (EnfoHea / 100 * OpHealthBonus);
            OpTommHealth = TommHea + (TommHea / 100 * OpHealthBonus);
            OpProfHealth = ProfHea + (ProfHea / 100 * OpHealthBonus);
            OpCourHealth = CourHea + (CourHea / 100 * OpHealthBonus);
            OpDeliHealth = DeliHea + (DeliHea / 100 * OpHealthBonus);

            OpThugHealth2 = (Convert.ToDouble(textBox30.Text) * ThugHea) + (Convert.ToDouble(textBox30.Text) * (ThugHea / 100 * OpHealthBonus));
            OpArsoHealth2 = (Convert.ToDouble(textBox29.Text) * ArsoHea) + (Convert.ToDouble(textBox29.Text) * (ArsoHea / 100 * OpHealthBonus));
            OpDemoHealth2 = (Convert.ToDouble(textBox28.Text) * DemoHea) + (Convert.ToDouble(textBox28.Text) * (DemoHea / 100 * OpHealthBonus));
            OpBruiHealth2 = (Convert.ToDouble(textBox27.Text) * BruiHea) + (Convert.ToDouble(textBox27.Text) * (BruiHea / 100 * OpHealthBonus));
            OpHitmHealth2 = (Convert.ToDouble(textBox26.Text) * HitmHea) + (Convert.ToDouble(textBox26.Text) * (HitmHea / 100 * OpHealthBonus));
            OpEnfoHealth2 = (Convert.ToDouble(textBox25.Text) * EnfoHea) + (Convert.ToDouble(textBox25.Text) * (EnfoHea / 100 * OpHealthBonus));
            OpTommHealth2 = (Convert.ToDouble(textBox24.Text) * TommHea) + (Convert.ToDouble(textBox24.Text) * (TommHea / 100 * OpHealthBonus));
            OpProfHealth2 = (Convert.ToDouble(textBox24.Text) * ProfHea) + (Convert.ToDouble(textBox23.Text) * (ProfHea / 100 * OpHealthBonus));
            OpCourHealth2 = (Convert.ToDouble(textBox22.Text) * CourHea) + (Convert.ToDouble(textBox22.Text) * (CourHea / 100 * OpHealthBonus));
            OpDeliHealth2 = (Convert.ToDouble(textBox21.Text) * DeliHea) + (Convert.ToDouble(textBox21.Text) * (DeliHea / 100 * OpHealthBonus));


            OpHealth = OpThugHealth2 + OpArsoHealth2 + OpDemoHealth2 + OpBruiHealth2 + OpHitmHealth2 + OpEnfoHealth2 + OpTommHealth2 + OpProfHealth2 + OpCourHealth2 + OpDeliHealth2;
            textBox31.Text = OpHealth.ToString();
        }

        private double getAttackBonus()
        {
            if (checkBox1.Checked)
            {
                return Convert.ToDouble(textBox1.Text) + Convert.ToDouble(textBox2.Text) + 35 + Convert.ToDouble(label21.Text);
            }
            else
            {
                return Convert.ToDouble(textBox1.Text) + Convert.ToDouble(textBox2.Text) + Convert.ToDouble(label21.Text);
            }
        }

        private double getHealthBonus()
        {
            if (checkBox1.Checked)
            {
                return Convert.ToDouble(textBox3.Text) + Convert.ToDouble(textBox4.Text) + 35 + Convert.ToDouble(label20.Text);
            }
            else
            {
                return Convert.ToDouble(textBox3.Text) + Convert.ToDouble(textBox4.Text) + Convert.ToDouble(label20.Text);
            }
        }

        private double getOpAttackBonus()
        {
            if (checkBox1.Checked)
            {
                return Convert.ToDouble(textBox20.Text) + Convert.ToDouble(textBox19.Text) + 35 + Convert.ToDouble(label35.Text);
            }
            else
            {
                return Convert.ToDouble(textBox20.Text) + Convert.ToDouble(textBox19.Text) + Convert.ToDouble(label35.Text);
            }
        }

        private double getOpHealthBonus()
        {
            if (checkBox1.Checked)
            {
                return Convert.ToDouble(textBox18.Text) + Convert.ToDouble(textBox17.Text) + 35 + Convert.ToDouble(label36.Text);
            }
            else
            {
                return Convert.ToDouble(textBox18.Text) + Convert.ToDouble(textBox17.Text) + Convert.ToDouble(label36.Text);
            }
        }

        #region getArmoryPerc
        private double getYoPerc1()
        {
            double result = 0;
            if (comboBox1.SelectedItem.ToString() == "Bronze")
            {
                result = arm.getBronzeLvlPercent(comboBox5.SelectedItem.ToString());
            }
            else if (comboBox1.SelectedItem.ToString() == "Silver")
            {
                result = arm.getSilverLvlPercent(comboBox5.SelectedItem.ToString());
            }
            else if (comboBox1.SelectedItem.ToString() == "Gold")
            {
                result = arm.getGoldLvlPercent(comboBox5.SelectedIndex.ToString());
            }
            textBox1.Text = result.ToString();
            return result;
        }

        private double getYoPerc2()
        {
            double result = 0;
            if (comboBox2.SelectedItem.ToString() == "Bronze")
            {
                result = arm.getBronzeLvlPercent(comboBox6.SelectedItem.ToString());
            }
            else if (comboBox2.SelectedItem.ToString() == "Silver")
            {
                result = arm.getSilverLvlPercent(comboBox6.SelectedItem.ToString());
            }
            else if (comboBox2.SelectedItem.ToString() == "Gold")
            {
                result = arm.getGoldLvlPercent(comboBox6.SelectedItem.ToString());
            }
            textBox2.Text = result.ToString();
            return result;
        }

        private double getYoPerc3()
        {
            double result = 0;
            if (comboBox3.SelectedItem.ToString() == "Bronze")
            {
                result = arm.getBronzeLvlPercent(comboBox7.SelectedItem.ToString());
            }
            else if (comboBox3.SelectedItem.ToString() == "Silver")
            {
                result = arm.getSilverLvlPercent(comboBox7.SelectedItem.ToString());
            }
            else if (comboBox3.SelectedItem.ToString() == "Gold")
            {
                result = arm.getGoldLvlPercent(comboBox7.SelectedItem.ToString());
            }
            textBox3.Text = result.ToString();
            return result;
        }

        private double getYoPerc4()
        {
            double result = 0;
            if (comboBox4.SelectedItem.ToString() == "Bronze")
            {
                result = arm.getBronzeLvlPercent(comboBox8.SelectedItem.ToString());
            }
            else if (comboBox4.SelectedItem.ToString() == "Silver")
            {
                result = arm.getSilverLvlPercent(comboBox8.SelectedItem.ToString());
            }
            else if (comboBox4.SelectedItem.ToString() == "Gold")
            {
                result = arm.getGoldLvlPercent(comboBox8.SelectedItem.ToString());
            }
            textBox4.Text = result.ToString();
            return result;
        }

        private double getYoPerc5()
        {
            double result = 0;
            if (comboBox18.SelectedItem.ToString() == "Bronze")
            {
                result = arm.getBronzeLvlPercent(comboBox14.SelectedItem.ToString());
            }
            else if (comboBox18.SelectedItem.ToString() == "Silver")
            {
                result = arm.getSilverLvlPercent(comboBox14.SelectedItem.ToString());
            }
            else if (comboBox18.SelectedItem.ToString() == "Gold")
            {
                result = arm.getGoldLvlPercent(comboBox14.SelectedIndex.ToString());
            }
            textBox20.Text = result.ToString();
            return result;
        }

        private double getYoPerc6()
        {
            double result = 0;
            if (comboBox15.SelectedItem.ToString() == "Bronze")
            {
                result = arm.getBronzeLvlPercent(comboBox13.SelectedItem.ToString());
            }
            else if (comboBox15.SelectedItem.ToString() == "Silver")
            {
                result = arm.getSilverLvlPercent(comboBox13.SelectedItem.ToString());
            }
            else if (comboBox15.SelectedItem.ToString() == "Gold")
            {
                result = arm.getGoldLvlPercent(comboBox13.SelectedItem.ToString());
            }
            textBox19.Text = result.ToString();
            return result;
        }

        private double getYoPerc7()
        {
            double result = 0;
            if (comboBox17.SelectedItem.ToString() == "Bronze")
            {
                result = arm.getBronzeLvlPercent(comboBox12.SelectedItem.ToString());
            }
            else if (comboBox17.SelectedItem.ToString() == "Silver")
            {
                result = arm.getSilverLvlPercent(comboBox12.SelectedItem.ToString());
            }
            else if (comboBox17.SelectedItem.ToString() == "Gold")
            {
                result = arm.getGoldLvlPercent(comboBox12.SelectedItem.ToString());
            }
            textBox18.Text = result.ToString();
            return result;
        }

        private double getYoPerc8()
        {
            double result = 0;
            if (comboBox16.SelectedItem.ToString() == "Bronze")
            {
                result = arm.getBronzeLvlPercent(comboBox11.SelectedItem.ToString());
            }
            else if (comboBox16.SelectedItem.ToString() == "Silver")
            {
                result = arm.getSilverLvlPercent(comboBox11.SelectedItem.ToString());
            }
            else if (comboBox16.SelectedItem.ToString() == "Gold")
            {
                result = arm.getGoldLvlPercent(comboBox11.SelectedItem.ToString());
            }
            textBox17.Text = result.ToString();
            return result;
        }
        #endregion

        private double getYoMusclePerc()
        {
            double result = 0;
            result = arm.getMusclePercent(comboBox10.Text.ToString());
            label21.Text = result.ToString();
            return result;
        }

        private double getYoMedPerc()
        {
            double result = 0;
            result = arm.getMedPercent(comboBox9.Text.ToString());
            label20.Text = result.ToString();
            return result;
        }

        private double getOpMusclePerc()
        {
            double result = 0;
            result = arm.getMusclePercent(comboBox19.Text.ToString());
            label35.Text = result.ToString();
            return result;
        }

        private double getOpMedPerc()
        {
            double result = 0;
            result = arm.getMedPercent(comboBox20.Text.ToString());
            label36.Text = result.ToString();
            return result;
        }


        private void comboBox9_SelectedIndexChanged(object sender, EventArgs e)
        {
            comboBox9.SelectedItem = comboBox9.Text.ToString();
            label20.Text = getYoMedPerc().ToString();
            yourAttackPower();
            yourHealthPower();
        }

        private void comboBox10_SelectedIndexChanged(object sender, EventArgs e)
        {
            comboBox10.SelectedItem = comboBox10.Text.ToString();
            label21.Text = getYoMusclePerc().ToString();
            yourAttackPower();
            yourHealthPower();
        }

        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {

        }

        private void checkBox2_CheckedChanged(object sender, EventArgs e)
        {

        }

        private void comboBox20_SelectedIndexChanged(object sender, EventArgs e)
        {
            comboBox20.SelectedItem = comboBox20.Text.ToString();
            label36.Text = getOpMedPerc().ToString();
            opAttackPower();
            opHealthPower();
        }

        private void comboBox19_SelectedIndexChanged(object sender, EventArgs e)
        {
            comboBox19.SelectedItem = comboBox19.Text.ToString();
            label35.Text = getOpMusclePerc().ToString();
            opAttackPower();
            opHealthPower();
        }

        #region YourTurn
        private void YourTurn(double end2)
        {
            if (end2 == 0)
            {

                if (YourAttack >= OpHealth)
                {
                    OpHealth = 0;
                    enemyTurn(0);
                }
                else
                {
                    while (OpHealth > 0)
                    {
                        for (int c1 = 0; c1 > YourList.Count; c1++)
                        {
                            foreach (Unit u1 in YourList)
                            {
                                foreach (Unit u2 in OpList)
                                {
                                    if (u1.AttackPower >= u2.Health)
                                    {
                                        u2.Health = 0;
                                        u1.AttackPower = u1.AttackPower - u2.Health;
                                        OpHealth = OpHealth - u2.Health;
                                    }
                                    else
                                    {
                                        u1.AttackPower = 0;
                                        u2.Health = u2.Health - u1.AttackPower;
                                        OpHealth = OpHealth - u2.Health;
                                    }
                                }
                            }
                        }

                        break;
                    }

                    if (OpHealth <= 0)
                    {
                        enemyTurn(0);
                    }
                    else
                    {
                        enemyTurn(OpHealth);
                    }
                }
            }
            else
            {
                foreach (Unit uToDie1 in YourList)
                {
                    if (uToDie1.Health <= 0)
                    { YourList.Remove(uToDie1); }
                }
            }


        }
        #endregion

        #region enemyTurn
        private void enemyTurn(double end)
        {

            if (OpAttack >= YourHealth)
            {
                YourHealth = 0;
                finish("Defeat");
            }
            else
            {
                while (YourHealth > 0)
                {
                    foreach (Unit u3 in OpList)
                    {
                        foreach (Unit u4 in YourList)
                        {
                            if (u3.AttackPower >= u4.Health)
                            {
                                u4.Health = 0;
                                u3.AttackPower = u3.AttackPower - u4.Health;
                                YourHealth = YourHealth - u4.Health;
                            }
                            else
                            {
                                u3.AttackPower = 0;
                                u4.Health = u4.Health - u3.AttackPower;
                                YourHealth = YourHealth - u4.Health;
                            }
                        }
                    }
                }

                if (end == 0)
                { finish("Victory"); }

                else if (YourHealth <= 0)
                {
                    finish("Defeat");
                }
                else
                {
                    foreach (Unit uToDie2 in OpList)
                    {
                        if (uToDie2.Health <= 0)
                        { OpList.Remove(uToDie2); }
                    }

                    YourTurn(YourHealth);
                }
            }

        }
        #endregion

        private void finish(string s)
        {
            if (s == "Victory")
            {
                label44.Text = "VICTORY";
            }
            else
            {
                label44.Text = "DEFEAT";
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            getYourUnitAmount();
            yourAttackPower();
            yourHealthPower();
            fillYourList();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            getOpUnitAmount();
            opAttackPower();
            opHealthPower();
            fillOpList();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            YourTurn(0);
        }

        private void fillYourList()
        {
            for (int i = 0; i < YThug; i++)
            {
                Unit u = new Unit();
                u.AttackPower = ThugAttack;
                u.Health = ThugHealth;
                YourList.Add(u);
            }

            for (int i2 = 0; i2 < YArso; i2++)
            {
                Unit u = new Unit();
                u.AttackPower = ArsoAttack;
                u.Health = ArsoHealth;
                YourList.Add(u);
            }

            for (int i3 = 0; i3 < YDemo; i3++)
            {
                Unit u = new Unit();
                u.AttackPower = DemoAttack;
                u.Health = DemoHealth;
                YourList.Add(u);
            }

            for (int i4 = 0; i4 < YBrui; i4++)
            {
                Unit u = new Unit();
                u.AttackPower = BruiAttack;
                u.Health = BruiHealth;
                YourList.Add(u);
            }

            for (int i5 = 0; i5 < YHitm; i5++)
            {
                Unit u = new Unit();
                u.AttackPower = HitmAttack;
                u.Health = HitmHealth;
                YourList.Add(u);
            }

            for (int i6 = 0; i6 < YEnfo; i6++)
            {
                Unit u = new Unit();
                u.AttackPower = EnfoAttack;
                u.Health = EnfoHealth;
                YourList.Add(u);
            }

            for (int i7 = 0; i7 < YTomm; i7++)
            {
                Unit u = new Unit();
                u.AttackPower = TommAttack;
                u.Health = TommHealth;
                YourList.Add(u);
            }

            for (int i7 = 0; i7 < YProf; i7++)
            {
                Unit u = new Unit();
                u.AttackPower = ProfAttack;
                u.Health = ProfHealth;
                YourList.Add(u);
            }

            for (int i7 = 0; i7 < YCour; i7++)
            {
                Unit u = new Unit();
                u.AttackPower = CourAttack;
                u.Health = CourHealth;
                YourList.Add(u);
            }

            for (int i7 = 0; i7 < YDeli; i7++)
            {
                Unit u = new Unit();
                u.AttackPower = DeliAttack;
                u.Health = DeliHealth;
                YourList.Add(u);
            }
        }

        private void fillOpList()
        {
            for (int i = 0; i < OThug; i++)
            {
                Unit u = new Unit();
                u.AttackPower = OpThugAttack;
                u.Health = OpThugHealth;
                OpList.Add(u);
            }

            for (int i2 = 0; i2 < OArso; i2++)
            {
                Unit u = new Unit();
                u.AttackPower = OpArsoAttack;
                u.Health = OpArsoHealth;
                OpList.Add(u);
            }

            for (int i3 = 0; i3 < ODemo; i3++)
            {
                Unit u = new Unit();
                u.AttackPower = OpDemoAttack;
                u.Health = OpDemoHealth;
                OpList.Add(u);
            }

            for (int i4 = 0; i4 < OBrui; i4++)
            {
                Unit u = new Unit();
                u.AttackPower = OpBruiAttack;
                u.Health = OpBruiHealth;
                OpList.Add(u);
            }

            for (int i5 = 0; i5 < OHitm; i5++)
            {
                Unit u = new Unit();
                u.AttackPower = OpAttack;
                u.Health = OpHealth;
                OpList.Add(u);
            }

            for (int i6 = 0; i6 < OEnfo; i6++)
            {
                Unit u = new Unit();
                u.AttackPower = OpEnfoAttack;
                u.Health = OpEnfoHealth;
                OpList.Add(u);
            }

            for (int i7 = 0; i7 < OTomm; i7++)
            {
                Unit u = new Unit();
                u.AttackPower = OpTommAttack;
                u.Health = OpTommHealth;
                OpList.Add(u);
            }

            for (int i8 = 0; i8 < OProf; i8++)
            {
                Unit u = new Unit();
                u.AttackPower = OpProfAttack;
                u.Health = OpProfHealth;
                OpList.Add(u);
            }

            for (int i9 = 0; i9 < OCour; i9++)
            {
                Unit u = new Unit();
                u.AttackPower = OpCourAttack;
                u.Health = OpCourHealth;
                OpList.Add(u);
            }

            for (int i10 = 0; i10 < ODeli; i10++)
            {
                Unit u = new Unit();
                u.AttackPower = OpDeliAttack;
                u.Health = OpDeliHealth;
                OpList.Add(u);
            }
        }
    }
}
